﻿<phone:PhoneApplicationPage 
    x:Class="WinMilk.Gui.TaskDetailsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:con="clr-namespace:WinMilk.Gui.Controls"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    shell:SystemTray.IsVisible="True">
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        
        <controls:Pivot Title="{Binding NameUpper}" Name="TaskDetailsPanel" DataContext="{Binding Task}">
            
			<!-- Task details -->
            <controls:PivotItem x:Name="TaskPivotItem" Header="{Binding Path=Loc.TaskDetailsHeader, Source={StaticResource L10N}}">
                
                <ScrollViewer>
                    <StackPanel Orientation="Vertical">
						
						<!-- Task Name and Priority -->
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20" />
                                <ColumnDefinition Width="5" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            
                            <Rectangle Grid.Column="0">
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{StaticResource PhoneChromeColor}" />
                                </Rectangle.Fill>
                            </Rectangle>

                            <Rectangle Grid.Column="0" Fill="{Binding PriorityColor}"/>

                            <TextBlock Grid.Column="2" Text="{Binding Name}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" TextWrapping="Wrap" />
                        </Grid>

                        <!-- Due time, time estimate and recurrence -->
						<Grid Margin="0,20,0,0" Visibility="{Binding HasDue, Converter={StaticResource VisibilityConverter}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Path=Loc.TaskWhenDetail, Source={StaticResource L10N}}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="0">
		        				<TextBlock.Foreground>
		        					<SolidColorBrush Color="{StaticResource PhoneBorderColor}"/>
		        				</TextBlock.Foreground>
                            </TextBlock>
							<StackPanel Orientation="Vertical" Grid.Column="1" >
                            	<TextBlock Text="{Binding LongDueDateString}" FontSize="{StaticResource PhoneFontSizeLarge}" TextWrapping="Wrap"/>
                                <!--<TextBlock Text="{Binding EstimateString}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Visibility="{Binding HasEstimate, Converter={StaticResource VisibilityConverter}}" TextWrapping="Wrap"/>-->
                                <!--<TextBlock Text="Repeats Weekly" FontSize="{StaticResource PhoneFontSizeMediumLarge}" TextWrapping="Wrap"/>-->
							</StackPanel>
                        </Grid>

                        <!-- List -->
						<Grid Margin="0,20,0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Path=Loc.TaskListDetail, Source={StaticResource L10N}}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="0">
		        				<TextBlock.Foreground>
		        					<SolidColorBrush Color="{StaticResource PhoneBorderColor}"/>
		        				</TextBlock.Foreground>
                            </TextBlock>
                            <TextBlock Text="{Binding List}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="1" TextWrapping="Wrap"/>
                        </Grid>

                        <!-- Tags -->
						<Grid Margin="0,20,0,0" Visibility="{Binding HasTags, Converter={StaticResource VisibilityConverter}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Path=Loc.TaskTagsDetail, Source={StaticResource L10N}}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="0">
		        				<TextBlock.Foreground>
		        					<SolidColorBrush Color="{StaticResource PhoneBorderColor}"/>
		        				</TextBlock.Foreground>
                            </TextBlock>
                            <TextBlock Text="{Binding TagsString}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="1" TextWrapping="Wrap"/>
                        </Grid>
						
						<!-- Location -->
						<!--<Grid Margin="0,20,0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Where" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="0">
		        				<TextBlock.Foreground>
		        					<SolidColorBrush Color="{StaticResource PhoneBorderColor}"/>
		        				</TextBlock.Foreground>
                            </TextBlock>
                            <TextBlock Text="Home" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="1" TextWrapping="Wrap"/>
                        </Grid>-->

                        <!-- URL -->
						<Grid Margin="0,20,0,0" Visibility="{Binding HasUrl, Converter={StaticResource VisibilityConverter}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Path=Loc.TaskURLDetail, Source={StaticResource L10N}}" FontSize="{StaticResource PhoneFontSizeLarge}" Grid.Column="0">
		        				<TextBlock.Foreground>
		        					<SolidColorBrush Color="{StaticResource PhoneBorderColor}"/>
		        				</TextBlock.Foreground>
                            </TextBlock>
                            <Button BorderThickness="0" Click="Url_Click" Grid.Column="1">
                                <TextBlock Text="{Binding Url}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}"/>
                            </Button>
                            
                        </Grid>
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>
			
			<!-- Notes -->
            <controls:PivotItem x:Name="NotesPivotItem" Header="{Binding Path=Loc.TaskNotesHeader, Source={StaticResource L10N}}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    
                    <!-- Add note button -->
                    <StackPanel Orientation="Horizontal" con:TiltEffect.IsTiltEnabled="True" Grid.Row="0">
                        <con:BigIconButton x:Name="AddNoteButton" Text="{Binding Path=Loc.TaskNotesAddButton, Source={StaticResource L10N}}" Type="add" Click="AddNoteButton_Click"/>
					</StackPanel>
						
					<!-- Notes list -->
                	<ListBox ItemsSource="{Binding Notes}" x:Name="NotesListBox" Grid.Row="1">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>

                        <ListBox.ItemTemplate>
                			<DataTemplate>
                				<!-- Note template -->
                                <StackPanel Margin="0,20,0,0">
                					<!-- Note title -->
                					<TextBlock Text="{Binding Title}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}" />
                						
									<!-- Note body -->
									<TextBlock Text="{Binding Body}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />
                                        
                                    <!-- Note edit and delete in context menu -->
                                    <toolkit:ContextMenuService.ContextMenu>
                                        <toolkit:ContextMenu>
                                            <toolkit:MenuItem Header="{Binding Path=Loc.TaskNotesEditButton, Source={StaticResource L10N}}" Click="EditNoteButton_Click"/>
                                            <toolkit:MenuItem Header="{Binding Path=Loc.TaskNotesDeleteButton, Source={StaticResource L10N}}" Click="DeleteNoteButton_Click"/>
                                        </toolkit:ContextMenu>
                                    </toolkit:ContextMenuService.ContextMenu>
                                </StackPanel>
                            </DataTemplate>
                		</ListBox.ItemTemplate>
                	</ListBox>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>

        <ProgressBar IsIndeterminate="{Binding IsLoading}" 
                 Visibility="{Binding IsLoading, Converter={StaticResource VisibilityConverter}}" 
                 Height="10" 
                 VerticalAlignment="Top" 
                 Margin="0,137,0,0" 
                 Style="{StaticResource PerformanceProgressBar}"/>
    </Grid>
</phone:PhoneApplicationPage>
